package cn.lili.controller.system.goods_auth;

import cn.lili.common.utils.ResultUtil;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.goods.entity.dto.GoodsSearchParams;
import cn.lili.modules.goods_auth.service.AuthSpaceGoodsService;
import cn.lili.modules.system.entity.dos.LiAuthSpaceGoods;
import cn.lili.modules.system.entity.dto.SpaceGoodsSearchParams;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/system/space_goods")
@Api(tags = "商品-空间管理")
public class AuthSpaceGoodsController {

    @Resource
    private AuthSpaceGoodsService authSpaceGoodsService;

    @ApiModelProperty(value = "空间商品分页列表")
    @GetMapping("/page")
    public ResultMessage<Object> spaceGoods(SpaceGoodsSearchParams searchParams){
        return ResultUtil.data(authSpaceGoodsService.spaceGoods(searchParams));
    }

    @ApiModelProperty(value = "添加商品")
    @PostMapping("/add")
    public ResultMessage<Object> addGoods(@RequestBody List<LiAuthSpaceGoods> spaceGoods){
        return ResultUtil.data(authSpaceGoodsService.addGoods(spaceGoods));
    }

    @ApiModelProperty(value = "批量删除商品")
    @DeleteMapping("/del/{ids}")
    public ResultMessage<Object> delGoods(@PathVariable List<String> ids){
        return ResultUtil.data(authSpaceGoodsService.delGoods(ids));
    }

    @ApiModelProperty(value = "选择商品")
    @PostMapping("/goodsList")
    public ResultMessage<Object> goodsList(@RequestBody GoodsSearchParams searchParams){
        return ResultUtil.data(authSpaceGoodsService.goodsList(searchParams));
    }

    @ApiModelProperty(value = "更新商品")
    @PutMapping("/updateList")
    public ResultMessage<Object> updateGoods(@RequestBody List<LiAuthSpaceGoods> spaceGoods){
        return ResultUtil.data(authSpaceGoodsService.updateGoods(spaceGoods));
    }
}
